]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Rename _allItems array to _orderedItems
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 31 Oct 2019 23:44:02 +0000 (00:44 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 5 Dec 2019 15:43:34 +0000 (15:43 +0000)
Since both the `_items` object and the `_allItems` array include the
same items, the difference between those variables seems unclear. The
real difference between them (except the different data type) is that
`_allItems` is ordered in the same order as the visible grid, so rename
`_allItems` to `_orderedItems` which makes that more obvious.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/799

js/ui/appDisplay.js

index 102197176874bd3458a5605caf95e88092268523..a39211f025eb43acbaeb255a8af0d3c6b750e97a 100644 (file)
@@ -166,7 +166,7 @@ var BaseAppView = GObject.registerClass({
         this._grid.x_expand = true;
 
         this._items = new Map();
-        this._allItems = [];
+        this._orderedItems = [];
     }
 
     _childFocused(_actor) {
@@ -174,7 +174,7 @@ var BaseAppView = GObject.registerClass({
     }
 
     _redisplay() {
-        let oldApps = this._allItems.slice();
+        let oldApps = this._orderedItems.slice();
         let oldAppIds = oldApps.map(icon => icon.id);
 
         let newApps = this._loadApps().sort(this._compareItems);
@@ -185,10 +185,10 @@ var BaseAppView = GObject.registerClass({
 
         // Remove old app icons
         removedApps.forEach(icon => {
-            let iconIndex = this._allItems.indexOf(icon);
+            let iconIndex = this._orderedItems.indexOf(icon);
             let id = icon.id;
 
-            this._allItems.splice(iconIndex, 1);
+            this._orderedItems.splice(iconIndex, 1);
             icon.destroy();
             this._items.delete(id);
         });
@@ -197,7 +197,7 @@ var BaseAppView = GObject.registerClass({
         addedApps.forEach(icon => {
             let iconIndex = newApps.indexOf(icon);
 
-            this._allItems.splice(iconIndex, 0, icon);
+            this._orderedItems.splice(iconIndex, 0, icon);
             this._grid.addItem(icon, iconIndex);
             this._items.set(icon.id, icon);
         });
@@ -206,7 +206,7 @@ var BaseAppView = GObject.registerClass({
     }
 
     getAllItems() {
-        return this._allItems;
+        return this._orderedItems;
     }
 
     _compareItems(a, b) {
@@ -431,9 +431,9 @@ var AllView = GObject.registerClass({
     _itemNameChanged(item) {
         // If an item's name changed, we can pluck it out of where it's
         // supposed to be and reinsert it where it's sorted.
-        let oldIdx = this._allItems.indexOf(item);
-        this._allItems.splice(oldIdx, 1);
-        let newIdx = Util.insertSorted(this._allItems, item, this._compareItems);
+        let oldIdx = this._orderedItems.indexOf(item);
+        this._orderedItems.splice(oldIdx, 1);
+        let newIdx = Util.insertSorted(this._orderedItems, item, this._compareItems);
 
         this._grid.removeItem(item);
         this._grid.addItem(item, newIdx);
@@ -441,9 +441,9 @@ var AllView = GObject.registerClass({
     }
 
     _refilterApps() {
-        let filteredApps = this._allItems.filter(icon => !icon.visible);
+        let filteredApps = this._orderedItems.filter(icon => !icon.visible);
 
-        this._allItems.forEach(icon => {
+        this._orderedItems.forEach(icon => {
             if (icon instanceof AppIcon)
                 icon.visible = true;
         });
@@ -1361,12 +1361,12 @@ class FolderView extends BaseAppView {
         let subSize = Math.floor(FOLDER_SUBICON_FRACTION * size);
         let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
 
-        let numItems = this._allItems.length;
+        let numItems = this._orderedItems.length;
         let rtl = icon.get_text_direction() == Clutter.TextDirection.RTL;
         for (let i = 0; i < 4; i++) {
             let bin = new St.Bin({ width: subSize * scale, height: subSize * scale });
             if (i < numItems)
-                bin.child = this._allItems[i].app.create_icon_texture(subSize);
+                bin.child = this._orderedItems[i].app.create_icon_texture(subSize);
             layout.attach(bin, rtl ? (i + 1) % 2 : i % 2, Math.floor(i / 2), 1, 1);
         }